<%@ page contentType="text/html; charset=utf-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>后台管理 - 爱购物-商城</title>
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/static/css/style.css"/>
</head>
<body>
<c:import url="/static/page/manager-header-nav.jsp">
    <c:param name="nav" value="product"/>
</c:import>
<div id="position" class="wrap">
    您现在的位置：<a href="${pageContext.request.contextPath}/index">爱购物-商城</a> &gt; 管理后台 &gt; 新增商品
</div>
<div id="main" class="wrap clearfix">
    <c:import url="/static/page/manage-left-nav.jsp"/>
    <div class="main">
        <h2>添加商品</h2>
        <div class="manage">
            <form action="${pageContext.request.contextPath}/manage/product/update" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
                <table class="form">
                    <input type="hidden" name="id" value="${product.id}">
                    <tr>
                        <td class="field"><label for="name">商品名称：</label></td>
                        <td><input id="name" type="text" class="text" name="name" value="${product.name}"/></td>
                    </tr>
                    <tr>
                        <td class="field"><label for="categoryId">所属分类：</label></td>
                        <td>
                            <select name="categoryId" id="categoryId">
                                <option value="-1">请选择分类</option>
                                <c:forEach var="c" items="${categories}">
                                    <c:if test="${!empty c.subCategories}">
                                        <optgroup label="${c.name}">
                                            <c:forEach var="sub" items="${c.subCategories}">
                                                <option value="${sub.id}" <c:if test="${product.categoryId eq sub.id}">selected</c:if>>${sub.name}</option>
                                            </c:forEach>
                                        </optgroup>
                                    </c:if>
                                </c:forEach>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td class="field"><label for="fileName">商品图片：</label></td>
                        <td><img src="${pageContext.request.contextPath}${product.fileName}" style="max-width: 400px"><input type="file" class="text" name="fileName" id="fileName"/></td>
                    </tr>
                    <tr>
                        <td class="field"><label for="fileName">商品价格：</label></td>
                        <td><input type="text" class="text tiny" name="price" id="price" value="${product.price}" /> 元</td>
                    </tr>
                    <tr>
                        <td class="field"><label for="description">描述：</label></td>
                        <td><input type="text" class="text" name="description" id="description" value="${product.description}"/></td>
                    </tr>
                    <tr>
                        <td class="field"><label for="stock">库存：</label></td>
                        <td><input type="text" class="text tiny" name="stock" id="stock" value="${product.stock}" /></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><label class="ui-blue"><input type="submit" name="submit" value="修改" /></label></td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<c:import url="/static/page/footer.jsp"/>
</body>
</html>

